home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!fatphil.demon.co.uk
- From: Phil Carmody <Phil@fatphil.demon.co.uk>
- Newsgroups: comp.lang.c++,comp.os.msdos.programmer
- Subject: Re: Timer (0x1C) Interrupt exactly 18.2 seconds?
- Date: Sun, 25 Feb 1996 21:07:26 GMT
- Organization: None
- Message-ID: <448372328wnr@fatphil.demon.co.uk>
- References: <4givrv$cim@midland.co.nz> <Dn9FMB.19s.0.sheppard@torfree.net>
- Reply-To: Phil@fatphil.demon.co.uk
- X-NNTP-Posting-Host: fatphil.demon.co.uk
- X-Broken-Date: Sunday, Feb 25, 1996 21.07.26
- X-Newsreader: Newswin Alpha 0.7
- X-Mail2News-Path: fatphil.demon.co.uk
-
- In article: <Dn9FMB.19s.0.sheppard@torfree.net> ak892@torfree.net (Bruce DeVisser) writes:
- >
- > Jarrod S Lowe (lowefam@igrin.co.nz) wrote:
- > : Hi
- >
- > : I have a C++ Program (on DOS) in which a function is attached to the
- > : Timer (0x1C) Interrupt.
- >
- > : [snip]
- >
- > : This program is expected to run, continually, for YEARS - so a drift
- > : that shows up in 5 minutes will make it unusable.
- >
- > : Does anybody have any ideas WHY this is happening?
- >
- > Yes; because the timer is not exactly 18.2 Hz. Try taking the oscillator
- > frequency -- 1.19318 MHz (which may drift slightly, so don't get too
- > carried away with precision), dividing it by 65536, and see what you come
- > up with.
- >
- > Bruce DeVisser
-
- This comes from the asm.x86 group, where we've just had a similar
- discussion
-
-
- In article: <3124955A.2EF1@hda.hydro.com> Terje Mathisen
- <Terje.Mathisen@hda.hydro.com> writes:
- > Here's another way to translate the 18.206...Hz ticks into
- > seconds: Multiply the ticks by the ratio 1913/34829 =
- > 18.20648196.
- >
- > This is the closest possible 16-bit only rational approximation
- > to the true value, it is probably more accurate than the clock
- > frequency of most PCs, so there's no need to try to improve upon
- > it.
-
- Sorry Terje,
- I beg to differ in the 8th significant digit!! I think you're hoisted
- with your own petard (in the shape of the 'probably' disclaimer).
-
- You assume Clock Frequency = 1193180 Hz
-
- I assume the following -
- NTSC clocks at 14318180Hz (look at the clock chips on your MB and VGA)
- Timer = NTSC/12 = 1193181.7 Hz
-
- We bath/all know that the DOS timer (typically) = Timer/65536
-
- For low/medium accuracy, we agree...
-
- approximate 18.206507364909 (my value)
- 18/1 = 18.000000000000 = 2.065074e-01 out (1st continued fraction)
- 55/3 = 18.333333333333 = 1.268260e-01 out
- 73/4 = 18.250000000000 = 4.349264e-02 out
- 91/5 = 18.200000000000 = 6.507365e-03 out (2nd continued fraction)
- 346/19 = 18.210526315789 = 4.018951e-03 out
- 437/24 = 18.208333333333 = 1.825968e-03 out
- 528/29 = 18.206896551724 = 3.891868e-04 out (4th continued fraction)
- 1147/63 = 18.206349206349 = 1.581586e-04 out
- 1675/92 = 18.206521739130 = 1.437422e-05 out
-
-
- For high accuracy, we diverge
-
- approximate 18.206507364909 (my value)
- 7847/431 = 18.206496519722 = 1.084519e-05 out
- 9522/523 = 18.206500956023 = 6.408886e-06 out
- 11197/615 = 18.206504065041 = 3.299868e-06 out
- 12872/707 = 18.206506364922 = 9.999866e-07 out
- 14547/799 = 18.206508135169 = 7.702601e-07 out
- 27419/1506 = 18.206507304117 = 6.079199e-08 out
-
- approximate 18.206481933594 (your value)
- 2822/155 = 18.206451612903 = 3.032069e-05 out
- 4497/247 = 18.206477732794 = 4.200800e-06 out
- 10669/586 = 18.206484641638 = 2.708044e-06 out
- 15166/833 = 18.206482593037 = 6.594435e-07 out
- 19663/1080 = 18.206481481481 = 4.521123e-07 out
- 34829/1913 = 18.206481965499 = 3.190546e-08 out
-
- So if you are going to pull some 'magic numbers' out of the bag, don't
- bother using either mine or Terje's, only used the shared values until
- some more evidence is found.
-
- If I'm right about the frequency, then 1675/92 is more accurate than
- any of your ratios would be, and vica versa. If we are both wrong, then
- probably both set of magic values will be rubbish!
-
- I use 528/29 and am happy with the 15 bits it gives me.
-
-
- Phil
-
-
- I then posted another, but have lost that - here's the gist
-
- the crystals on a pc typically are 100ppm. That's roughly
- 8.6 seconds per day, or 1.82e-03s per clock tick.
-
-
- So it looks like it's bad news on the accuracy front...
- Phil
- --
- Phil Carmody
- The views expressed herein are mine, so no ripping them off OK!
-
-
-
-
-
- --
- Phil Carmody
- The views expressed herein are mine, so no ripping them off OK!
-
-